# -*- encoding=utf8 -*-
        
__author__ = "Bryan.Chen"
__desc__=""
        
from airtest.core.api import *
        
auto_setup(__file__)
        
from poco.drivers.std import StdPoco
poco = StdPoco()
        
using("../FlowTest.air")
import FlowTest
        
class SubGame_BackToHall(FlowTest.BaseTestCase):
    def __init__(self):
        print("%s __init__" % (__file__))
        
    def runTest(self, args):
        print("%s runTest" % (__file__))

        isH5 = False
        isMini = False
        isGoldBean = False
        if "isH5" in args:
            isH5 = args["isH5"]

        if "isMini" in args:
            isMini = args["isMini"]

        if "isGoldBean" in args:
            isGoldBean = args["isGoldBean"]

        if isH5:
            time.sleep(3.0)
            keyevent("BACK")
            keyevent("BACK")
        elif isMini:
            time.sleep(3.0)
            # 退出小程序
            keyevent("BACK")
            keyevent("BACK")
            # 退出微信
            keyevent("BACK")
        elif isGoldBean:
            btnBack = poco("JDCLobbyScene").offspring("back_btn")
            if btnBack.exists():
                self.clickButton(btnBack)

            btnHall = poco("HjLobbyScene").offspring("dating_button")
            if btnHall.exists():
                self.clickButton(btnHall)
        else:
            btnBack = poco("Button_Back")
            self.clickButton(btnBack)

        return True
        
_instance = SubGame_BackToHall()
runTest = _instance.runTest
